var app=getApp();
Page({
    data:{
        dataArray:[],
        index:1,
        ID:''
    },
    onReady:function(){
    // 生命周期函数--监听页面初次渲染完成
    },
    onLoad:function(option){
        wx.setNavigationBarTitle({
        title: option.title,
        })
        this.setData({
            ID:option.id
        })
        this.netForGameListInfo()
    },
    // 游戏
    netForGameListInfo:function(){
    var that = this;
    app.showHud()
    wx.request({
      url: 'http://lol.video.luckyamy.com/api/?cat=jieshuo&',
      data: {
          id:that.data.ID,
          page:that.data.index,
          ap:'lol',
          ver:'1.3',
      },
      header: {
      },
      success: function(res) {
        console.log("game=====success")
        console.log(res.data)
        that.setData({
          dataArray:res.data,
        })
      },
      fail: function (res) {
        console.log("failed")
      }
    })
  },
  // 下拉刷新
  upperGamelist: function () {
    var that = this;
    wx.showNavigationBarLoading()
    that.setData({
       index:1,
    }),
    this.netForGameListInfo();
    console.log("upper");
    setTimeout(function(){wx.hideNavigationBarLoading();wx.stopPullDownRefresh();}, 2000);
  },
  // 上拉加载
  lowerGamelist: function (e) {
    wx.showNavigationBarLoading();
    var that = this;
    that.setData({
       index:that.data.index+1,
    }),
    console.log(that.data.index);
    setTimeout(function(){wx.hideNavigationBarLoading();that.netRequestMore();}, 1000);
    console.log("lower")
  },
  netRequestMore:function(){
    var that = this;
    app.showHud()
    wx.request({
      url: 'http://lol.video.luckyamy.com/api/?cat=jieshuo&',
      data: {
          id:that.data.ID,
          page:that.data.index,
          ap:'lol',
          ver:'1.3',
      },
      header: {
      },
      success: function(res) {
        console.log("=====success")
        console.log(res.data)
        that.setData({
          dataArray:that.data.dataArray.concat(res.data),
        })
      },
      fail: function (res) {
        console.log("failed")
      }
    })
  },
});